<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <!--<li>
                            关联客户信息的id：<input type="text" name="userId"/>
                        </li>-->

                       <!-- <li>
                            签到次数：<input type="text" name="signCount"/>
                        </li>-->

                        <!--<li>
                            修改时间：<input type="date" name="updateTime"/>
                        </li>-->

                    <!--    <li>
                            签到时间：<input type="date" name="signTime"/>
                        </li>-->
                        <!--会员搜索条件-->
                        <li>
                            学员姓名：<input type="text" name="cardUserName"/>
                        </li>
                        <li>
                            学员卡号：<input type="text" name="cardId"/>
                        </li>
                        <li>
                            手机号码：<input type="text" name="phoneNumber"/>
                        </li>

                        <li>
                            销售顾问：<input type="text" name="loginName"/>
                        </li>
                       <!-- <li>
                            办卡类型：<input type="text" name="cardStyle"/>
                        </li>-->
                     <!--   <li>
                            班级类型：<input type="text" name="classType"/>
                        </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
           <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="attend:daySign:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
               shiro:hasPermission="attend:daySign:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="attend:daySign:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="attend:daySign:export">
                <i class="fa fa-download"></i> 导出
            </a>
          <!--  <a class="btn btn-danger " onclick="$.operate.attendAll()" shiro:hasPermission="attend:daySign:sign">
                <i class="fa fa-star-half-o"></i> 打卡
            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('attend:daySign:edit')}]];
    var removeFlag = [[${@permission.hasPermi('attend:daySign:remove')}]];
    var datas = [[${@dict.getType('sys_user_sex')}]];
    var signFlag = [[${@permission.hasPermi('attend:daySign:sign')}]];
    var prefix = ctx + "attend/daySign";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            attendUrl: prefix + "/signPlus",
            modalName: "签到",
            search: false,
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'signId',
                    title: '签到表id',
                    visible: false
                },

                {
                    field: 'dayUser.avatar',
                    title: '头像',
                    align: 'center',
                    iconSize: 'xs',
                    formatter: function (value, row, index) {
                        //图片回显
                        var imgUrl = "/avatar" + row.avatar;
                        if (row.avatar == '' || row.avatar == null) {
                            imgUrl = "/img/profile.jpg";
                        }
                        return '<img src=' + imgUrl + ' class="img-rounded" style="width:50px;height:50px;" >'
                    }
                },
                {
                    field: 'dayUser.cardId',
                    title: '学员卡号'
                },
                {
                    field: 'dayUser.cardUserName',
                    title: '学员姓名'
                },
                {
                    field: 'dayUser.loginName',
                    title: '课程顾问'
                },
                {
                    field: 'dayUser.phoneNumber',
                    title: '电话'
                },
                {
                    field: 'dayUser.sex',
                    title: '性别',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                    /* formatter: function() {
                         // @{/profile/avatar/} + ${value.avatar}
                         var actions = [];
                         actions.push("<span><img th:src='@{/img/profile.jpg}'  alt='image' class='img-circle' height='60' width='60'/></span>");
                         return actions.join('');
                     }*/
                },
                {
                    field: 'dayUser.classType',
                    title: '课堂类型'
                },
                {
                    field: 'dayUser.cardStyle',
                    title: '办卡类型',
                    align: 'center'
                    /* formatter: function(value, row, index) {
                         return $.table.selectDictLabel(datas, value);
                     }*/
                },
                {
                    field: 'dayUser.classCount',
                    title: '课时数量'
                },
                {
                    field: 'dayUser.pastTime',
                    title: '到期时间',
                    sortable: true
                },


                {
                    field: 'signCount',
                    title: '签到次数'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        /*actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.signId + '\')"><i class="fa fa-edit"></i>编辑</a> ');*/
                       actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.signId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-primary btn-xs ' + signFlag + '" href="#" onclick="$.operate.attend(\'' + row.signId + '\')"><i class="fa fa-star"></i>打卡</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function searchAll() {
        var url = ctx + "listAll";
        var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
        var params = $("#bootstrap-table").bootstrapTable('getOptions');
        params.queryParams = function(params) {
            var search = {};
            $.each($("#" + currentId).serializeArray(), function(i, field) {
                search[field.name] = field.value
            });
            search.pageSize = params.limit;
            search.pageNum = params.offset / params.limit + 1;
            search.searchValue = params.search;
            search.orderByColumn = params.sort;
            search.isAsc = params.order;
            return search;
        }
        $("#bootstrap-table").bootstrapTable('refresh', params);
    }
</script>
</body>
</html>